#{extends 'assistant_main.html' /}

#{set 'moreScripts'}

<script type="text/javascript">

    $(function () {
        // -------- add vendor dialog
        $('#add_div').dialog({
            autoOpen:false,
            width:600,
            modal:true,
            resizable: false,
            buttons:{
                "保存":function () {
                    if ($("#name").val().trim() == "") {
                        jqAlert("请填写厂商名称");
                    } else {
                        $("#add_user_form").submit();
                        $(this).dialog("close");
                    }
                },
                "取消":function () {
                    $(this).dialog("close");
                }
            }
        });

        // Dialog Link
        $('#create_link').click(function () {
            $('#add_div').css('display', '');
            $('#add_div').dialog('open');
            return false;
        });

        // -------- edit vendor dialog
        $('#edit_div').dialog({
            autoOpen:false,
            width:600,
            modal:true,
            resizable:false,
            buttons:{
                "保存":function () {
                    $("#edit_form").submit();
                    $(this).dialog("close");
                },
                "取消":function () {
                    $(this).dialog("close");
                }
            }
        });



    });


    var detailForEditAction = #{jsAction @Vendors.detailForEdit(':id') /}

    function showEditForm(venId,venName) {
        $('#edit_table_div').load(detailForEditAction({id:venId}), function () {});
        $("#edit_entity_id").val(venId);
        $('#edit_div').css('display', '');
        $('#edit_div').dialog('option', "title", "修改厂商（" + venName + "）基本信息");
        $('#edit_div').dialog('open');
    }
</script>
#{/set}


<h1 id="title">厂商管理</h1>
<div class="light_bar">
${entityList.size()} / ${entityCount} 厂商
    &nbsp;
    <a href="#" id="create_link" class="ui-state-default ui-corner-all dialog_button">
        <span class="ui-icon ui-icon-newwin"></span>新增厂商</a>

    <label for="keyword" style="margin-left: 30px">名称：</label><input type="text" name="keyword" id="keyword" maxlength="30"/>
    <a href="javascript:jqAlert('暂未实现，建造中……')" id="search_link" class="ui-state-default ui-corner-all big_opt_button">搜索</a>

#{pagination page:pageSequence ?: 1, size:entityCount /}
</div>


<table id="func_list">
    <thead>
    <tr>
        <th class="main" width="12%">名称</th>
        <th class="main" width="15%">地址</th>
        <th class="main" width="100px">电话</th>*{电话1和电话2，分行}*
        <th class="main" width="100px">传真</th>
        <th class="main" width="140px">联系人</th>*{两组人名：电话，分行}*
        <th class="main" width="110px">备注</th>
        <th class="main" width="70px">创建时间</th>
        <th width="100px">操作</th>
    </tr>
    </thead>
#{if entityList.size()>0}
    #{list items:entityList, as:'ven'}
        <tr>
            <td class="main">${ven.name}</td>
            <td class="main">${ven.address}</td>
            <td class="main">
            ${ven.phone}#{if ven.phone2!=null && ven.phone2!=''},<br/>${ven.phone2}#{/if}
            </td>
            <td class="main">${ven.fax}</td>
            <td class="main">
                ${ven.contactPerson}/${ven.contactPersonMobile}
                #{if ven.contactPerson2!=null && ven.contactPerson2!=''},<br/>
                ${ven.contactPerson2}/${ven.contactPersonMobile2}#{/if}
            </td>
            <td class="main">${ven.remark}</td>
            <td class="main">${ven.createDate.format("yyyy-MM-dd")}</td>
            <td class="main">
                <a class="ui-state-default ui-corner-all opt_button" href="javascript:showEditForm('${ven.id}','${ven.name}');">编辑</a>
                <a class="ui-state-default ui-corner-all opt_button" href="javascript:requireActionByPost('@{Vendors.delete}','${ven.id}','确定删除厂商(${ven.name})？');">删除</a>
            </td>
        </tr>
    #{/list}
#{/if}
</table>



<div id="add_div" style="display: none;" title="新增厂商">
    <form id="add_user_form" action="@{Vendors.create()}" method="post">
        <table class="myTable">
            <tr>
                <td align="right" class="input_label" width="15%"><label for="name"
                                                                         class="input_required">名称：</label></td>
                <td width="30%"><input id="name" name="name" type="text" maxlength="50"/></td>
                <td align="right" class="input_label" width="20%"><label for="address">地址：</label></td>
                <td width="35%"><input id="address" name="address" type="text" maxlength="50"/></td>
            </tr>
            <tr>
                <td align="right" class="input_label"><label for="phone">电话：</label></td>
                <td><input id="phone" name="phone" type="text" maxlength="50"/></td>
                <td align="right" class="input_label"><label for="phone2">电话2：</label></td>
                <td><input id="phone2" name="phone2" type="text" maxlength="50"/></td>
            </tr>
            <tr>
                <td align="right" class="input_label"><label for="fax">传真：</label></td>
                <td><input id="fax" name="fax" type="text" maxlength="50"/></td>
                <td align="right" class="input_label"><label for="remark">备注：</label></td>
                <td><input id="remark" name="remark" type="text" maxlength="50"/></td>
            </tr>
            <tr>
                <td align="right" class="input_label"><label for="contactPerson">联系人：</label></td>
                <td><input id="contactPerson" name="contactPerson" type="text" maxlength="50"/></td>
                <td align="right" class="input_label"><label for="contactPersonMobile">联系人电话：</label></td>
                <td><input id="contactPersonMobile" name="contactPersonMobile" type="text" maxlength="50"/></td>
            </tr>
            <tr class="no_bottom">
                <td align="right" class="input_label no_bottom"><label for="contactPerson2">联系人2：</label></td>
                <td class="no_bottom"><input id="contactPerson2" name="contactPerson2" type="text" maxlength="50"/></td>
                <td align="right" class="input_label no_bottom"><label for="contactPersonMobile2">联系人电话2：</label></td>
                <td class="no_bottom"><input id="contactPersonMobile2" name="contactPersonMobile2" type="text" maxlength="50"/></td>
            </tr>
        </table>
    </form>
</div>


<div id="edit_div" style="display: none;" title="编辑组织信息">
    #{form @edit(), id:'edit_form',method:'POST'}
        <input type="hidden" id="edit_entity_id" name="userId" value=""/>
        <div id="edit_table_div">
            *{这里由ajax引入后台html代码}*
        </div>
    #{/form}
</div>